Optimizing the stack size of recursive functions
نویسندگان
چکیده
For memory constrained environments, optimization for program size is often as important as, if not more important than, optimization for execution speed. Commonly, compilers try to reduce the code segment but neglect the stack segment, although the stack can significantly grow during the execution of recursive functions because a separate activation record is required for each recursive call. If a formal parameter or local variable is dead at all recursive calls, then it can be declared global so that only one instance exists independent of the recursion depth. We found that in 70% of our benchmark functions, it is possible to reduce the stack size by declaring formal parameters and local variables global. Often, live ranges of formal parameters and local variables can be split at recursive calls through program transformations. These splitting transformations allowed us to further optimize the stack size of all our benchmark functions. If all formal parameters and local variables can be declared global, then such functions may be transformable into iterations. This was possible for all such benchmark functions.
منابع مشابه
An Integrated Approach for Non-Recursive Formulation of Connection- Coefficients of Orthogonal Functions
In this paper, an integrated approach is proposed for non-recursive formulation of connection coefficients of different orthogonal functions in terms of a generic orthogonal function. The application of these coefficients arises when the product of two orthogonal basis functions are to be expressed in terms of single basis functions. Two significant advantages are achieved; one, the non-recursi...
متن کاملThe Subtree Size Profile of Bucket Recursive Trees
Kazemi (2014) introduced a new version of bucket recursive trees as another generalization of recursive trees where buckets have variable capacities. In this paper, we get the $p$-th factorial moments of the random variable $S_{n,1}$ which counts the number of subtrees size-1 profile (leaves) and show a phase change of this random variable. These can be obtained by solving a first order partial...
متن کاملOn the Multiplicative Zagreb Indices of Bucket Recursive Trees
Bucket recursive trees are an interesting and natural generalization of ordinary recursive trees and have a connection to mathematical chemistry. In this paper, we give the lower and upper bounds for the moment generating function and moments of the multiplicative Zagreb indices in a randomly chosen bucket recursive tree of size $n$ with maximal bucket size $bgeq1$. Also, we consi...
متن کاملOptimizing the performance of migration in two ways
In this paper two approaches are used to reduce the computational work of a migration algorithm. The first approach uses a stepwise optimization procedure for the recursive extrapolation routines used in the migration program. And in the second approach the properties of CFP gathers are used to calculate an image of good quality by using less shot record migrations than in a full pre-stack shot...
متن کاملBranches in random recursive k-ary trees
In this paper, using generalized {polya} urn models we find the expected value of the size of a branch in recursive $k$-ary trees. We also find the expectation of the number of nodes of a given outdegree in a branch of such trees.
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- Computer Languages, Systems & Structures
دوره 35 شماره
صفحات -
تاریخ انتشار 2009